package com.example.bbfindhouse.Activity;

import android.os.Bundle;
import android.widget.ListView;

import androidx.appcompat.app.AppCompatActivity;

import com.example.bbfindhouse.Adapter.LeaseItemAdapter;
import com.example.bbfindhouse.R;

import java.util.ArrayList;
import java.util.List;

public class zuyueActivity extends AppCompatActivity {

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.zuyue);

        // 获取 ListView 控件
        ListView leaseListView = findViewById(R.id.main_list);

        // 模拟添加租约数据
        List<LeaseItem> leaseItemList = new ArrayList<>();
        leaseItemList.add(new LeaseItem("ic_house1", "远洋国际公寓 2室1厅", "朝阳区 CBD 商圈", "租约进行中", "2023.08 - 2024.08", "¥6800/月"));
        leaseItemList.add(new LeaseItem("ic_house2", "望京SOHO 1室1厅", "朝阳区 望京", "租约已结束", "2022.08 - 2023.08", "¥5500/月"));

        // 创建适配器
        LeaseItemAdapter adapter = new LeaseItemAdapter(this, R.layout.lease_item, leaseItemList);

        // 设置适配器到 ListView
        leaseListView.setAdapter(adapter);
    }

    // 定义租约数据类
    public static class LeaseItem {
        private String imageRes;
        private String title;
        private String location;
        private String status;
        private String time;
        private String price;

        public LeaseItem(String imageRes, String title, String location, String status, String time, String price) {
            this.imageRes = imageRes;
            this.title = title;
            this.location = location;
            this.status = status;
            this.time = time;
            this.price = price;
        }

        public String getImageRes() {
            return imageRes;
        }

        public String getTitle() {
            return title;
        }

        public String getLocation() {
            return location;
        }

        public String getStatus() {
            return status;
        }

        public String getTime() {
            return time;
        }

        public String getPrice() {
            return price;
        }
    }
}